Arm assembly caesar cipher encryption -


i'm new arm assembly , i'm using armsim school project. have multiple problems.

  1. i need read multiple lines txtfile , each line has string take 85 bytes(per line). program reads first line, don't know how read rest of file.
  2. i have take each character each line , add 13 if character value i'll call "a" ((a>=65 && a<=77) || (a>=97 && a<=109)). have subtract 13 if ((a>=78 && a<=109)||(a>=110 && a<=122)). if (a==32) print out space , move onto next character.i don't understand how using branches...

the loop processes character character , prints character out stdout. here code far... i've spent days & hours on , can't wrap head around this. have been exposed java till now.

.equ swi_open, 0x66 @open file .equ swi_close,0x68 @close file .equ swi_prchr,0x00 @ write ascii char stdout .equ swi_prstr, 0x69 @ write null-ending string .equ swi_print,0x6b @ write integer .equ swi_rdint,0x6c @ read integer file .equ swi_rdstr, 0x6a @ read string file .equ stdout, 1 @ set output target stdout .equ swi_exit, 0x11 @ stop execution .global _start .text _start:  ldr r0,=infilename @ set name input file mov r1,#0 @ mode input swi swi_open @ open file input ldr r1,=infilehandle str r0,[r1] ldr r7,[r1] ldr r1,=array mov r2,#85 swi swi_rdstr @stores string =array   mov r5,#0 @r5 index  loop: @processes single char loops cmp r5,r2 @r2 83 bge procstop ldrb r4,[r1,r5] @loads character value =array[r5] r4  cmp r4,#77 ble add cmp r4,#65 bge add  cmp r4,#97 bge add cmp r4,#109  ble add  cmp r4,#78 bge sub cmp r4,#90 ble sub  cmp r4,#110 bge sub cmp r4,#122 ble sub  add: add r4,r4,#13  sub: sub r4,r4,#13  mov r0,r4 swi swi_prchr  strb r4,[r1,r5] add r5,r5,#1 b loop procstop:  mov r0,#stdout swi swi_prstr swi swi_exit  .data infilename: .asciz "lab4.txt" endoffilemsg: .asciz "end of file reached\n" colonspace: .asciz": " nl: .asciz "\n " @ new line array: .skip 85 .align infilehandle: .word 0   .end 

ah figured out. didn't know why didn't think of sooner. don't need compare of those, needed each comparison 1 @ time smallest comparison largest, chain of if/else if statements


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -